<?php
namespace app\send\logic\msg;
use app\send\logic\msg\Msg;
use \think\Config;
/**
 * 阿里短信
 */
class AliMsg extends Msg
{
    /**
     * [发送验证码]
     * @param  [type] $phone [手机号]
     * @param  [type] $code  [验证码]
     * @return [type]        [description]
     */
	public function index($phone,$code){
        vendor("send.ali.api_demo.SmsDemo");
        $config = Config::get('alicode');
        
        $msg = new \SmsDemo($config['app_key'],$config['app_secret']);
        $response = $msg->sendSms(
            $config['sign'], // 短信签名
            $config['number'], // 短信模板编号
            $phone, // 短信接收者
            Array(  // 短信模板中字段的值
                "code"=>$code,
                "product"=>"dsd"
            ),
            "123"
        ); 
        if ($response->Code == 'OK') {
            $mg['code'] = 1;
            
        } else {
            $mg['code'] = 0;
            $mg['msg'] = $response->Message;
          
        } 
        return $mg;
    }
}

